<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>

<form:form commandName="task" cssClass="form-horizontal" role="form" onsubmit="return false;">
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">任务单号:</label>
        <div class="col-sm-4">
            <input type="text" placeholder="任务单号" readonly="readonly"
                   value="${task.sysId}" class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="taskName">任务名称:</label>
        <div class="col-sm-4">
            <input type="text" name="taskName" id="taskName" placeholder="任务名称" readonly="readonly"
                   value="${task.taskName}" class="form-control ">
        </div>
    </div>
    <%--<div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="industryName">指标名称:</label>
        <div class="col-sm-4">
            <input type="text" name="industryName" id="industryName" placeholder="指标名称" readonly="readonly"
                   value="${task.industryName}" class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right" for="taskName">指标时间:</label>
        <div class="col-sm-4">
            <input type="text" name="industryDate" id="industryDate" placeholder="指标时间" readonly="readonly"
                   value="${task.industryDate}" class="form-control ">
        </div>
    </div>--%>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="taskContent">任务内容:</label>
        <div class="col-sm-10">
            <textarea rows="2" id="taskContent" name="taskContent" readonly="readonly" placeholder="任务内容"
                      class="form-control ">${task.taskContent}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="task-methon-id">*督查方式:</label>

        <div class="col-sm-4">
            <select name="methodCode" class="form-control " style="width: 100%"
                    data-placeholder="督查方式" id="task-methon-id" required>
                <option value="">请选择您本次的督查方式</option>
                    <%--<option value="${summaryFilter.teamId }">${summaryFilter.teamClass }</option>--%>
                <c:forEach items="${methods}" var="methods">
                    <option value="${methods.methodCode }">${methods.methodName }</option>
                </c:forEach>
            </select>
        </div>
        <label class="col-sm-2 control-label no-padding-right">*督查日期:</label>
        <div class="col-sm-4">
            <input id="selectTime" type="text" name="datatime" class="form-control date-picker"
                   placeholder="点击选择时间"  required/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="taskContent">*督查记录:</label>
        <div class="col-sm-10">
            <textarea rows="3" id="record" name="record" <%--value="${task.record}"--%> class="form-control"
                      placeholder="请填写催办记录" required/>
        </div>
    </div>


    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">当前指标情况:</label>

        <div class="col-sm-4">
            <input type="text" name="supervision-Result" id="supervision-Result" readonly="readonly"
                    class="form-control ">
        </div>
        <label class="col-sm-2 control-label no-padding-right">任务时限:</label>
        <div class="col-sm-4">
            <input type="number" name="deadline" id="deadline" placeholder="填写天数" maxlength="2" min="1" max="99"
                   class="form-control ">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="supervisionAsk">*督查要求:</label>
        <div class="col-sm-10">
            <textarea rows="2" id="supervisionAsk" name="supervisionAsk" class="form-control"
                      placeholder="请填写督查要求" required/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">*佐证材料:</label>
        <input class="col-sm-6" type="file" id="fileupload" name="files" />
        <button class="col-sm-3 btn btn-large btn-primary" id="btn-upload">上传</button>
    </div>

    <hr width="100%;height:2px;">
    <c:if test="${not empty listRecords}">
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right formsHead"
                   for="taskContent">责任单位反馈情况:</label>
        </div>
    </c:if>
    <c:forEach items="${listRecords}" var="listRecords">
        <div class="form-group">
            <label class="col-sm-1 control-label no-padding-right">反馈时间</label>
            <div class="col-sm-2">
                <input type="text" value="${listRecords.dataTime}"
                       placeholder="" readonly="readonly" class="form-control ">
            </div>
            <div class="col-sm-3">
                <button class="btn btn-sm btn-primary downloadFile" data-id="${listRecords.taxproof}"
                        style="width: 100%;">
                    下载附件
                </button>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label no-padding-right">完成情况</label>
            <div class="col-sm-11">
                <textarea rows="2" class="form-control" readonly="readonly">${listRecords.record}</textarea>
            </div>
        </div>
        <hr width="100%;height:2px;">
    </c:forEach>

    <c:if test="${not empty supervisionLogs}">
        <div class="form-group">
            <label class="col-sm-2 control-label no-padding-right formsHead" for="taskContent">督查组反馈情况:</label>
        </div>
    </c:if>
    <c:forEach items="${supervisionLogs}" var="logs">
        <div class="form-group">
            <label class="col-sm-1 control-label no-padding-right">督查日期</label>
            <div class="col-sm-2">
                <input type="text" value="${logs.dataTime}" readonly="readonly"
                       class="form-control ">
            </div>

            <label class="col-sm-1 control-label no-padding-right">督查方式</label>
            <div class="col-sm-3">
                <input type="text" value="${logs.methodName}" readonly="readonly"
                       placeholder="未填写" class="form-control">
            </div>

            <div class="col-sm-3">
                <button class="btn btn-sm btn-primary downloadFile" data-id="${logs.taxproof}" style="width: 100%;">
                    下载附件
                </button>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label no-padding-right">填写日期</label>
            <div class="col-sm-2">
                <input type="text" value="${logs.createDate}" readonly="readonly" class="form-control">
            </div>

            <label class="col-sm-1 control-label no-padding-right">任务时限</label>
            <div class="col-sm-2">
                <c:choose>
                    <c:when test="${not empty logs.deadline}">
                        <input type="number" readonly="readonly" value="${logs.deadline}" maxlength="2" min="1" max="99"
                               class="form-control ">
                    </c:when>
                    <c:otherwise>
                        <input type="number" readonly="readonly" placeholder="无" value="${logs.deadline}" maxlength="2"
                               min="1" max="99" class="form-control ">
                    </c:otherwise>
                </c:choose>
            </div>
            <label class="col-sm-1 control-label no-padding-right">督查要求</label>
            <div class="col-sm-5">
                <textarea rows="1   " class="form-control" readonly="readonly">${logs.supervisionAsk}</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-1 control-label no-padding-right">督查记录</label>
            <div class="col-sm-11">
                <textarea rows="2" class="form-control" readonly="readonly">${logs.record}</textarea>
            </div>

        </div>
        <hr width="100%;height:2px;">
    </c:forEach>

    <%--下载--%>
    <input type="text" name="taxproof" id="taxproof_proof" hidden>
    <form:hidden path="sysId"/>
</form:form>
<div class="row" style="margin-left: 25px;">
    * 以上按住如此标志：<img src="/assets/web/img/zzc.png"  alt="提示" />可拖动调整相应输入框大小
</div>
<script src="<s:url value="/assets/js/ajaxfileupload.js"></s:url>"></script>
<script type="text/javascript">
    /**
     * 下载
     */
    $(".downloadFile").click(function () {
        var id = $(this).data("id");
        var url = "/communal/download/" + id;
        window.open(url);
    });

    /**
     * 上传材料
     */
    $("#btn-upload").click(function () {
        var fileval = $("#fileupload").val();
        if (fileval == null || fileval == "") {
            alert("未选择任何文件");
            return;
        }

        $(".shade").fadeIn(100);
        $(".warning").fadeIn(100);
        $('.la-square-jelly-box').show();
        showShade();
        //警告框自定义内容
        $('.warning>.title>em').html('加载中……');
        $.ajaxFileUpload({
            type: "post",
            fileElementId: "fileupload",
            secureuri: false,
            dataType: 'text',
            url: "/communal/uploadBatch",
            // data:fileinfo,
            async: false,
            success: function (data) {
                var data = JSON.parse(data);
                console.log(data);
                var val = data.data.sysid;
                console.log(val);
                $("#taxproof_proof").attr("value", val);
                if (data.code === "200") {
                    $('.warning>.title>em').html('上传成功');
                } else {
                    $('.warning>.title>em').html('上传失败');
                }
            },
            error: function (data) {
                alert("佐证材料上传失败 ！！请联系管理员");
            }
        });
    });


    jQuery(function ($) {
        $('.date-picker').datepicker({
            inline: true,
            format: "yyyymmdd",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        }).next().on(ace.click_event, function () {
            $(this).prev().focus();
        });

        $(".downloadFile").each(function(){
            if(isEmpty($(this).data("id"))){
                $(this).attr("style","display:none;");
            }
        });


        var nodeSysId = '${nodeSysId}';
        var nodeStatus;
        // $.ajax({
        //     type: "GET",
        //     url: "/api/nodes/checkNodeIsFinished",
        //     dataType: "json",
        //     data: {nodeSysId: nodeSysId},
        //     success: function (model) {
        //         console.log(model);
        //         if (model.code == "200") {
        //             if(model.data){
        //                 console.log(model.message);
        //                 //节点已完成
        //                 nodeStatus = "1";
        //                 $('#supervision-Result').val("督查节点:已完成");
        //             }else{
        //                 console.log(model.message);
        //                 //节点未完成
        //                 nodeStatus = "0";
        //                 $('#supervision-Result').val("督查节点:未完成");
        //             }
        //         }else{
        //             console.log("数据错误，没有该节点！")
        //         }
        //     },
        //     error: function (model) {
        //     }
        // });
    });



    // $("#task-methon-id").change(function () {
    //     var change = $("#task-methon-id").val();
    //     if (change == 'AA') {
    //         $("#fileupload").removeAttr("required");
    //     }else{
    //         $("#fileupload").attr("required",true);
    //     }
    // })


</script>